package xyz.xtt.asset.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.entity.TblAssetTransaction;
import xyz.xtt.asset.service.IMystryBoxService;

@RefreshScope
@Slf4j
@Component
public class ConfirmTransactionListener implements ApplicationListener<ConfirmTransactionEvent> {

	@Autowired
	private IMystryBoxService mystryBoxService;

	@Override
	public void onApplicationEvent(ConfirmTransactionEvent event) {
		TblAssetTransaction transaction = event.getTransaction();
		Boolean sendOpen = mystryBoxService.sendOpen(transaction);
		log.info("onApplicationEvent:{},fsendOpen:{}", JSONUtil.toJsonStr(event), sendOpen);
	}

}
